package cn.hrfax.stf.sdk.integration.remote;

import cn.hrfax.stf.sdk.model.*;
import org.springframework.stereotype.Service;

import cn.hrfax.stf.sdk.integration.abs.AbstractCarRemote;
import lombok.extern.slf4j.Slf4j;

/**
 * @author yongSen.wang
 * @date 2020/6/15 18:10
 */
@Slf4j
@Service
public class TradeRemoteImpl extends AbstractCarRemote implements TradeRemote {

    @Override
    public RemoteResponse applyCredit(ApplyCreditParams params) {
        final String remoteName = "tradeRemote_applyCredit";
        final String urlPath = "/bank/route";
        final String busiCode = "1001";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }

    @Override
    public RemoteResponse stagesInput(StagesInputParams params) {
        final String remoteName = "tradeRemote_stagesInput";
        final String urlPath = "/bank/route";
        final String busiCode = "1002";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }

    @Override
    public RemoteResponse confirmation(ConfirmationParams params) {
        final String remoteName = "tradeRemote_stagesInput";
        final String urlPath = "/bank/route";
        final String busiCode = "1008";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }

    @Override
    public RemoteResponse applyTrade(ApplyTradeParams params) {

        final String remoteName = "tradeRemote_applyTrade";
        final String urlPath = "/api/trade/route";
        final String busiCode = "DR1001";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }

    @Override
    public RemoteResponse queryTradeResult(QueryTradeParams params) {
        final String remoteName = "tradeRemote_queryTradeResult";
        final String urlPath = "/api/trade/route";
        final String busiCode = "DR1002";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }

    @Override
    public RemoteResponse queryOrganConfig() {
        final String remoteName = "tradeRemote_queryOrganConfig";
        final String urlPath = "/api/trade/route";
        final String busiCode = "DR2001";
        return callRemote(remoteName, urlPath, null, null, busiCode);
    }

    @Override
    public RemoteResponse openCard(OpenCardParams params) {
        final String remoteName = "tradeRemote_openCard";
        final String urlPath = "/bank/route";
        final String busiCode = "1003";
        return callRemote(remoteName, urlPath, params.getOrderNo(), params, busiCode);
    }
}
